package com.edu.exam.enums.curriculum;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 批量操作类型枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum BatchOperationType implements BaseEnum {
    BATCH_CREATE("BATCH_CREATE", "批量创建"),
    BATCH_UPDATE("BATCH_UPDATE", "批量更新"),
    BATCH_DELETE("BATCH_DELETE", "批量删除"),
    BATCH_IMPORT("BATCH_IMPORT", "批量导入"),
    BATCH_EXPORT("BATCH_EXPORT", "批量导出"),
    BATCH_STATUS_CHANGE("BATCH_STATUS_CHANGE", "批量状态变更"),
    BATCH_CATEGORY_ASSIGN("BATCH_CATEGORY_ASSIGN", "批量分类分配"),
    BATCH_TAG_ASSIGN("BATCH_TAG_ASSIGN", "批量标签分配"),
    BATCH_DIFFICULTY_ADJUST("BATCH_DIFFICULTY_ADJUST", "批量难度调整"),
    BATCH_APPROVAL("BATCH_APPROVAL", "批量审批");

    private final String code;
    private final String description;

    BatchOperationType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static BatchOperationType fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            throw new IllegalArgumentException("BatchOperationType code cannot be null or empty");
        }
        for (BatchOperationType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown BatchOperationType code: " + code);
    }

    public static BatchOperationType fromDescription(String description) {
        if (description == null || description.trim().isEmpty()) {
            throw new IllegalArgumentException("BatchOperationType description cannot be null or empty");
        }
        for (BatchOperationType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown BatchOperationType description: " + description);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}